//
//  ClosureA.swift
//  swiftStudy
//
//  Created by unisedu on 16/4/1.
//  Copyright © 2016年 CaoFei. All rights reserved.
//

import UIKit
//14.闭包（Closure） 类似block
class ClosureA: NSObject {
    func backwards(s1:String,s2:String) ->Bool{
        return s1>s2
    }
    
    func show(){
        
        
        let names = ["aa","bb","cc","dd"]
        
        
        
        var reversed = sort(s1:names,s2:backwards)
        for str in reversed{
            println(str)
        }
        
        //block
        
        var reversed2 = sort (names , {(s1 : String , s2 : String) -> Bool in
            return s1>s2
            }
        )
        for str in reversed2{
            println(str)
        }
    }
    
}
